package de.baumann.browser.activitys.hash

import android.content.Context
import android.content.Intent
import de.baumann.browser.R
import de.baumann.browser.adapter.MiningIncomeAdapter
import de.baumann.browser.api.net.vo.MiningIncome
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.IMiningIncomeView
import de.baumann.browser.present.MiningIncomePresenter
import de.baumann.browser.utils.getUser
import kotlinx.android.synthetic.main.activity_mining_income.*
import kotlinx.android.synthetic.main.include_tool_bar.*

class MiningIncomeActivity : BaseOdinActivity<IMiningIncomeView, MiningIncomePresenter>(), IMiningIncomeView {

    companion object {
        fun startMiningIncomeActivity(context: Context) {
            context.startActivity(Intent(context, MiningIncomeActivity::class.java))
        }
    }

    private lateinit var miningIncomeAdapter: MiningIncomeAdapter

    override fun getLayout(): Int {
        return R.layout.activity_mining_income
    }

    override fun getTitleText(): String {
        return "挖矿收益"
    }

    override fun initView() {
        initToolbar(commToolBar, commTitle)
        miningIncomeAdapter = MiningIncomeAdapter()
        rvMiningIncome.adapter = miningIncomeAdapter
        miningIncomeAdapter.setEmptyView(R.layout.empty_view,rvMiningIncome)
    }

    override fun initData() {
        presenter.getMiningIncome()
    }

    override fun createPresenter(): MiningIncomePresenter {
        return MiningIncomePresenter()
    }

    override fun createView(): IMiningIncomeView {
        return this
    }

    override fun getAddress(): String {
        return getUser()?.eth_address.toString()
    }

    override fun setIncomes(incomes: List<MiningIncome>) {
        miningIncomeAdapter.setNewData(incomes)
    }
}
